package com.qipay.doc.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class BaseController  {
    @Value("${web.static.url.host}")
    protected String StaticHost;

    @Value("${web.host}")
    protected String webHost;

    protected ModelAndView createModelAndView(HttpServletRequest request, String name){
        ModelAndView modelAndView = new ModelAndView(name);
        modelAndView.addObject("StaticHost", StaticHost);
        modelAndView.addObject("webHost", webHost);

        HttpSession session = request.getSession();
        String isOn = (String) session.getAttribute("isOn");
        if("on".equals(isOn)){
            modelAndView.addObject("isOn", "on");
        }else{
            modelAndView.addObject("isOn", "off");
        }
        return modelAndView;
    }
}
